package com.lvideo.component.extraplayer;

import android.content.Context;

import com.lvideo.component.extraplayer.utils.MyPlayerConstant;
import com.lvideo.component.extraplayer.videoview.VideoViewBestvProxy;
import com.lvideo.component.extraplayer.videoview.VideoViewFunshionProxy;
import com.lvideo.component.extraplayer.videoview.VideoViewLetvProxy;
import com.lvideo.component.extraplayer.videoview.VideoViewPPTVProxy;
import com.lvideo.component.extraplayer.videoview.VideoViewPasterProxy;
import com.lvideo.component.extraplayer.videoview.VideoViewTencentProxy;
import com.novaplayer.LetvMediaPlayerControl;
import com.novaplayer.LetvVideoViewBuilder;

/**
 * Author: liuxiaojiang(liuxiaojiang)
 * Date: 2017-02-10
 * Time: 11:01
 * Description: FIXME
 */
public class LVideoVideoViewBuilder {

    private static LVideoVideoViewBuilder mLVideoVideoViewBuilder = null;

    private static LetvVideoViewBuilder mLetvVideoViewBuilder = null;

    public static LVideoVideoViewBuilder getInstants() {
        if (mLVideoVideoViewBuilder == null) {
            createBuilder();
        }
        return mLVideoVideoViewBuilder;
    }

    private synchronized static void createBuilder(){
        if(mLVideoVideoViewBuilder==null){
            mLVideoVideoViewBuilder = new LVideoVideoViewBuilder();
            mLetvVideoViewBuilder = LetvVideoViewBuilder.getInstants();
        }
    }

    private LVideoVideoViewBuilder() {

    }

    public LetvMediaPlayerControl build(Context context, int type) {
        LetvMediaPlayerControl mLetvMediaPlayerControl = null;
        switch (type){
            case MyPlayerConstant.MOBILE_MY_M3U8:
                mLetvMediaPlayerControl = mLetvVideoViewBuilder.build(context, LetvVideoViewBuilder.Type.SW_COMMON);
                break;
            case MyPlayerConstant.MOBILE_MY_MP4:
                mLetvMediaPlayerControl = mLetvVideoViewBuilder.build(context, LetvVideoViewBuilder.Type.DEFAULT);
                break;
            case MyPlayerConstant.MOBILE_TENCENT_SDK:
                mLetvMediaPlayerControl = new VideoViewTencentProxy(context);
                break;
            case MyPlayerConstant.MOBILE_PPTV_SDK:
                mLetvMediaPlayerControl = new VideoViewPPTVProxy(context);
                break;
            case MyPlayerConstant.MOBILE_LETV_SDK:
                mLetvMediaPlayerControl = new VideoViewLetvProxy(context);
                break;
            case MyPlayerConstant.MOBILE_FUNSHION_SDK:
                mLetvMediaPlayerControl = new VideoViewFunshionProxy(context);
                break;
            case MyPlayerConstant.MOBILE_BESTV_SDK:
                mLetvMediaPlayerControl = new VideoViewBestvProxy(context);
                break;
            case MyPlayerConstant.MOBILE_PASTER_SDK:
                mLetvMediaPlayerControl = new VideoViewPasterProxy(context);
                break;
            default:
                mLetvMediaPlayerControl = mLetvVideoViewBuilder.build(context, LetvVideoViewBuilder.Type.DEFAULT);
                break;
        }

        return mLetvMediaPlayerControl;
    }
}
